{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# sklearn中的多项式回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = np.random.uniform(-3, 3, 100)\n",
    "X = x.reshape(-1, 1)\n",
    "y = 0.5 * x ** 2 + x + 2 + np.random.normal(0, 1, size = 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import PolynomialFeatures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PolynomialFeatures(degree=2, include_bias=True, interaction_only=False)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "poly = PolynomialFeatures(degree=2)\n",
    "poly.fit(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "X2 = poly.transform(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(100, 3)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X2.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[  1.00000000e+00,   2.72821821e+00,   7.44317463e+00],\n",
       "       [  1.00000000e+00,   3.94902821e-01,   1.55948238e-01],\n",
       "       [  1.00000000e+00,  -2.47298506e+00,   6.11565513e+00],\n",
       "       [  1.00000000e+00,   6.35546884e-02,   4.03919842e-03],\n",
       "       [  1.00000000e+00,   1.41034344e+00,   1.98906862e+00]])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X2[:5,:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 2.72821821],\n",
       "       [ 0.39490282],\n",
       "       [-2.47298506],\n",
       "       [ 0.06355469],\n",
       "       [ 1.41034344]])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X[:5,:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LinearRegression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "lin_reg = LinearRegression()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lin_reg.fit(X2, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_predict = lin_reg.predict(X2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3Xl8VNX5x/HPSYgQQAgILkQQVERFrECsRXBfQESMVKvWhbZWtPbnUi0Wd9wqFos7tSi1LoiKQhAVoRCqqAUNBkUUFBXB4B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UWe9uS5Bhjso0xS4FvgP9Ya5N+Pr4J6MaYecaY98N8nApgrb3OWtsVmAL8n7etjS7a86k95jpgG85z8rVYnk+Gi2nDFvGWMaYt8DxwRYM794xjra221h6Cc4f+c2NM0mmxpFZbdJO19vgYD30KeAm4KYXNSVq052OMGQkMA46zGTCQEcfvJ1Npwxafq801Pw9MsdZO97o9brHWVhhj/gsMAZIawPZND70pxpiedT4dDqzwqi1uMMYMAf4CDLfWbvK6PQJowxZfqx1EnAx8aK2d4HV7kmWM6RyqbjPG5ALH40Jcy5Qql+eBXjiVFJ8DF1try7xtVeKMMauAlsD62ocWZXjVzmnA/UBnoAJYaq0d7G2r4meMGQrcw44NW273uElJMcZMBY7GWc3va+Ama+1kTxuVIGPMIGAhsAwnDgBcW7snQ8YxxhwMPIbzWssCnrXW3pL0eTMhoIuISHQZkXIREZHoFNBFRAJCAV1EJCAU0EVEAkIBXUQkIBTQRUQCQgFdRCQgFNBFRALi/wG7Q4gMmzRXfgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10ff131d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(x, y)\n",
    "plt.plot(np.sort(x), y_predict[np.argsort(x)], color= 'r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.        ,  0.88489971,  0.48557716])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lin_reg.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.0648420344067402"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lin_reg.intercept_"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Pipeline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.pipeline import Pipeline\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "pipe = Pipeline([\n",
    "    (\"poly\", PolynomialFeatures(degree=2)),\n",
    "    (\"std_scaler\", StandardScaler()),\n",
    "    (\"lin_reg\", LinearRegression())\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Pipeline(memory=None,\n",
       "     steps=[('poly', PolynomialFeatures(degree=2, include_bias=True, interaction_only=False)), ('std_scaler', StandardScaler(copy=True, with_mean=True, with_std=True)), ('lin_reg', LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False))])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pipe.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_predict = pipe.predict(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3Xl8VNX5x/HPSYgQQAgILkQQVERFrECsRXBfQESMVKvWhbZWtPbnUi0Wd9wqFos7tSi1LoiKQhAVoRCqqAUNBkUUFBXB4BLRiEiAkJzfHzcDWWYy2525d26+79crL8jk5t4zyeSZc5/znHOMtRYREcl8WV43QERE3KGALiISEAroIiIBoYAuIhIQCugiIgGhgC4iEhAK6CIiAaGALiISEAroIiIB0SKdF+vUqZPt3r17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bdJO19vgYD30KeAm4KYXNSVq052OMGQkMA46zGTCQEcfvJ1Npwxafq801Pw9MsdZO97o9brHWVhhj/gsMAZIawPZND70pxpiedT4dDqzwqi1uMMYMAf4CDLfWbvK6PQJowxZfqx1EnAx8aK2d4HV7kmWM6RyqbjPG5ALH40Jcy5Qql+eBXjiVFJ8DF1try7xtVeKMMauAlsD62ocWZXjVzmnA/UBnoAJYaq0d7G2r4meMGQrcw44NW273uElJMcZMBY7GWc3va+Ama+1kTxuVIGPMIGAhsAwnDgBcW7snQ8YxxhwMPIbzWssCnrXW3pL0eTMhoIuISHQZkXIREZHoFNBFRAJCAV1EJCAU0EVEAkIBXUQkIBTQRUQCQgFdRCQgFNBFRALi/wG7Q4gMmzRXfgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x11064a860>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(x, y)\n",
    "plt.plot(np.sort(x), y_predict[np.argsort(x)], color= 'r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
